<template>
  <div class="waterChargeQuery">
    <div class="formm">
   
      <el-form :model="user" status-icon  ref="user" label-width="100px" class="demo-ruleForm">
       <el-form-item label="用户卡号" prop="card">
    <el-input type="text" v-model="user.card" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="验证码" prop="checkData">
    <el-input type="text" v-model="user.checkData" autocomplete="off"></el-input>
    <font style="color:red">身份证后六位</font>
  </el-form-item>
    <el-form-item label="查询内容" prop="choice">
    <el-radio-group v-model="user.choice">
      <el-radio label="欠费查询"></el-radio>
      <el-radio label="缴费记录"></el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="submitForm()">立即查询</el-button>
  </el-form-item>
</el-form>
    </div>
  </div>
</template>

<style>
    .waterChargeQuery{
          width: 560px;
          height: 460px;
          margin: 0 auto;
          background: url(https://picnew9.photophoto.cn/20150826/qianlansepugongyingbeijingtupian-08146164_1.jpg)  no-repeat;
          background-size: 100% auto;
          /* margin-top: 150px; */
          position: relative;
    }
    .formm{
      width: 480px;
      height: 460px;
      /* background-color: black; */
      position: absolute;
        margin-top: 50px;
        margin-left: 30px;
    }
</style>
<script>
export default {
   name:'WaterChargeQuery',
   data() {
      return{
        user:{
          card:'',
          checkData:'',
          choice:'欠费查询',
        }
      }
  },
  methods:{
    submitForm(){
      // console.log(this.user.choice=="欠费查询");
        if(this.user.choice=="欠费查询"){
          this.$http.get("/user/waterQuery",{params:{card:this.user.card,idCard:this.user.checkData}})
          .then((result) => {
            // console.log(result);
            if(result.data.status){
              // console.log(result.data.object);
              this.$url.setCard(this.user.card);
              this.$url.setIdCard(this.user.checkData);

               this.$router.push({
              path:"/arrears",
              query:{arrearsData:result.data.object}
        })
            }
            else{
              alert(result.data.message)
            }
        }
        ).catch((err) => {
            console.error(err);
        });
           }
        else{
            // console.log(this.user.checkData);
            console.log("=================");
          this.$http.get("/user/paymentForm",{params:{card:this.user.card,idCard:this.user.checkData}})
          .then((result) => {
            console.log(result);
            if(result.data.status){
              // console.log(result.data.object);
              this.$url.setCard(this.card);
              this.$url.setIdCard(this.card);
               this.$router.push({
              path:"/paymentHistory",
              query:{arrearsData:result.data.object}
        })
        }
            else{
              alert(result.data.message)
            }
        }
        ).catch((err) => {
            console.error(err);
        });   
        }
    },

  },
  mounted(){
    this.user.card=this.$url.state.card;
    this.user.checkData=this.$url.state.idCard;
    // console.log(this.card);
  }
}
</script>